<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
  <script src="../js/babel.js"></script>
</head>

<body>
  <div id="root"></div>
</body>

</html>

<script type="text/babel">
  // 函数式组件 添加state 状态
  function Example() {
    const [counter, setCounter] = React.useState(0)

    return (
      <div>
        <p>you click {counter} times</p>
        <button onClick={() => { setCounter(counter + 1) }}>
          Click me
      </button>
      </div>
    )
  }

  ReactDOM.render(<Example />, document.getElementById('root'))

</script>